﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ahao.LeetCode.Simple.demo1185
{
    /// <summary>
    /// 1185. 一周中的第几天
    /// </summary>
    public class Class1185
    {
        public string DayOfTheWeek(int day, int month, int year)
        {
            string[] week = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
            int[] monthDays = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30 };
            /* 输入年份之前的年份的天数贡献 */
            int days = 365 * (year - 1971) + (year - 1969) / 4;
            /* 输入年份中，输入月份之前的月份的天数贡献 */
            for (int i = 0; i < month - 1; ++i)
            {
                days += monthDays[i];
            }
            if ((year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) && month >= 3)
            {
                days += 1;
            }
            /* 输入月份中的天数贡献 */
            days += day;
            return week[(days + 3) % 7];
        }
    }
}
